
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <sys/time.h>
#include "app_platform/cntl_info.h"
#include "app_platform/cgi_stub_cntl.h"
#include "../include/gismapgatewayao_stub4web_allinone.h"
#include "erp/gis/po/coordinatespo_gis.h"	
#include <map>	
#include <vector>	
#include "erp/gis/po/coordinatesquerypo_gis.h"	

using namespace erp::gis::ao;

void Init()
{       
	if(CCGI_STUB_CNTL->Initialize(true) != 0)
		std::cerr << "CCGI_STUB_CNTL->Init failed" << std::endl;
	CCGI_STUB_CNTL->setTimeout(20);
}
void TestGetAliyunCoordinates()
{
	//TODO 如果使用配置中心来获取APP地址,请注释下行
	CCGI_STUB_CNTL->setPeerAddr("10.12.192.209", 53101);

	//TODO 请设置用户Passport
	CCntlInfo oCntlInfo;
	oCntlInfo.setOperatorUin(88883687);
	oCntlInfo.setOperatorClientIP(0);
	oCntlInfo.setOperatorKey("stw3ymf9uk");
	//TODO 请设置路由值
	oCntlInfo.setRouteKey(88883687);
	std::string machineKey = "shellexchen";		
	std::string source = "shellex";		
	uint32_t sceneId = 0;
	erp::gis::po::CCoordinatesQueryPo coordinatesQueryPo;
    //coordinatesQueryPo.SetDestAddrProvince("");
    coordinatesQueryPo.SetDestAddrCity("深圳市");
    coordinatesQueryPo.SetDestAddrDistrict("");
	coordinatesQueryPo.SetDestAddrDetail("深圳市腾讯大厦");
	std::string inReserve = "";		
	std::vector<erp::gis::po::CCoordinatesPo > coordinatesPo;
	std::string errMsg = "";		
	std::string outReserve = "";		
	CGisMapGatewayAoStub4Web oStub;
	// TODO:替换函数参数
    uint32_t dwResult = oStub.GetAliyunCoordinates(
		oCntlInfo,
		machineKey,
		source,
		sceneId,
		coordinatesQueryPo,
		inReserve,
		coordinatesPo,
		errMsg,
		outReserve
  	);
    if(dwResult == 0)
	{
		std::cout << "Invoke OK!" << std::endl;
		printf("OK result[0x%x], time = %ld\n"
        , dwResult, oStub.GetLastConsumeTime());
        for(std::vector<erp::gis::po::CCoordinatesPo >::iterator iter = coordinatesPo.begin(); iter != coordinatesPo.end(); ++iter )
        {
            std::stringstream oss;
            iter->DumpData(oss);
            std::cout << oss.str() << std::endl;
        }

	}
	else
    {
        printf("Error result[0x%x], time = %ld , errmsg = [%s]\n"
        , dwResult, oStub.GetLastConsumeTime(),oStub.GetLastErrMsg());
    }
}
void TestGetBaiduCoordinates()
{
	//TODO 如果使用配置中心来获取APP地址,请注释下行
	CCGI_STUB_CNTL->setPeerAddr("10.12.192.209", 53101);

	//TODO 请设置用户Passport
	CCntlInfo oCntlInfo;
	oCntlInfo.setOperatorUin(88883687);
	oCntlInfo.setOperatorClientIP(0);
	oCntlInfo.setOperatorKey("stw3ymf9uk");
	//TODO 请设置路由值
	oCntlInfo.setRouteKey(88883687);
	std::string machineKey = "shellexchen";		
	std::string source = "shellex";		
	uint32_t sceneId = 0;
	erp::gis::po::CCoordinatesQueryPo coordinatesQueryPo;
    //coordinatesQueryPo.SetDestAddrProvince("");
    coordinatesQueryPo.SetDestAddrCity("深圳市");
    coordinatesQueryPo.SetDestAddrDistrict("");
	coordinatesQueryPo.SetDestAddrDetail("深圳市腾讯大厦");
	std::string inReserve = "";		
	std::vector<erp::gis::po::CCoordinatesPo > coordinatesPo;
	std::string errMsg = "";		
	std::string outReserve = "";		
	CGisMapGatewayAoStub4Web oStub;
	// TODO:替换函数参数
    uint32_t dwResult = oStub.GetBaiduCoordinates(
		oCntlInfo,
		machineKey,
		source,
		sceneId,
		coordinatesQueryPo,
		inReserve,
		coordinatesPo,
		errMsg,
		outReserve
  	);
    if(dwResult == 0)
	{
		std::cout << "Invoke OK!" << std::endl;
		printf("OK result[0x%x], time = %ld\n"
        , dwResult, oStub.GetLastConsumeTime());
        for(std::vector<erp::gis::po::CCoordinatesPo >::iterator iter = coordinatesPo.begin(); iter != coordinatesPo.end(); ++iter )
        {
            std::stringstream oss;
            iter->DumpData(oss);
            std::cout << oss.str() << std::endl;
        }

	}
	else
    {
        printf("Error result[0x%x], time = %ld , errmsg = [%s]\n"
        , dwResult, oStub.GetLastConsumeTime(),oStub.GetLastErrMsg());
    }
}
void TestGetGaodeCoordinates()
{
	//TODO 如果使用配置中心来获取APP地址,请注释下行
	CCGI_STUB_CNTL->setPeerAddr("10.12.192.209", 53101);

	//TODO 请设置用户Passport
	CCntlInfo oCntlInfo;
	oCntlInfo.setOperatorUin(88883687);
	oCntlInfo.setOperatorClientIP(0);
	oCntlInfo.setOperatorKey("stw3ymf9uk");
	//TODO 请设置路由值
	oCntlInfo.setRouteKey(88883687);
	std::string machineKey = "shellexchen";		
	std::string source = "shellex";		
	uint32_t sceneId = 0;
	erp::gis::po::CCoordinatesQueryPo coordinatesQueryPo;
    //coordinatesQueryPo.SetDestAddrProvince("");
    coordinatesQueryPo.SetDestAddrCity("深圳市");
    coordinatesQueryPo.SetDestAddrDistrict("");
	coordinatesQueryPo.SetDestAddrDetail("深圳市腾讯大厦");
	std::string inReserve = "";		
	std::vector<erp::gis::po::CCoordinatesPo > coordinatesPo;
	std::string errMsg = "";		
	std::string outReserve = "";		
	CGisMapGatewayAoStub4Web oStub;
	// TODO:替换函数参数
    uint32_t dwResult = oStub.GetGaodeCoordinates(
		oCntlInfo,
		machineKey,
		source,
		sceneId,
		coordinatesQueryPo,
		inReserve,
		coordinatesPo,
		errMsg,
		outReserve
  	);
    if(dwResult == 0)
	{
		std::cout << "Invoke OK!" << std::endl;
		printf("OK result[0x%x], time = %ld\n"
        , dwResult, oStub.GetLastConsumeTime());
        for(std::vector<erp::gis::po::CCoordinatesPo >::iterator iter = coordinatesPo.begin(); iter != coordinatesPo.end(); ++iter )
        {
            std::stringstream oss;
            iter->DumpData(oss);
            std::cout << oss.str() << std::endl;
        }

	}
	else
    {
        printf("Error result[0x%x], time = %ld , errmsg = [%s]\n"
        , dwResult, oStub.GetLastConsumeTime(),oStub.GetLastErrMsg());
    }
}
void TestGetGoogleCoordinates()
{
	//TODO 如果使用配置中心来获取APP地址,请注释下行
	CCGI_STUB_CNTL->setPeerAddr("10.12.192.209", 53101);

	//TODO 请设置用户Passport
	CCntlInfo oCntlInfo;
	oCntlInfo.setOperatorUin(88883687);
	oCntlInfo.setOperatorClientIP(0);
	oCntlInfo.setOperatorKey("stw3ymf9uk");
	//TODO 请设置路由值
	oCntlInfo.setRouteKey(88883687);
	std::string machineKey = "shellexchen";		
	std::string source = "shellex";		
	uint32_t sceneId = 0;
	erp::gis::po::CCoordinatesQueryPo coordinatesQueryPo;
    //coordinatesQueryPo.SetDestAddrProvince("");
    coordinatesQueryPo.SetDestAddrCity("深圳市");
    coordinatesQueryPo.SetDestAddrDistrict("");
	coordinatesQueryPo.SetDestAddrDetail("深圳市腾讯大厦");
	std::string inReserve = "";		
	std::vector<erp::gis::po::CCoordinatesPo > coordinatesPo;
	std::string errMsg = "";		
	std::string outReserve = "";		
	CGisMapGatewayAoStub4Web oStub;
	// TODO:替换函数参数
    uint32_t dwResult = oStub.GetGoogleCoordinates(
		oCntlInfo,
		machineKey,
		source,
		sceneId,
		coordinatesQueryPo,
		inReserve,
		coordinatesPo,
		errMsg,
		outReserve
  	);
    if(dwResult == 0)
	{
		std::cout << "Invoke OK!" << std::endl;
		printf("OK result[0x%x], time = %ld\n"
        , dwResult, oStub.GetLastConsumeTime());
        for(std::vector<erp::gis::po::CCoordinatesPo >::iterator iter = coordinatesPo.begin(); iter != coordinatesPo.end(); ++iter )
        {
            std::stringstream oss;
            iter->DumpData(oss);
            std::cout << oss.str() << std::endl;
        }

	}
	else
    {
        printf("Error result[0x%x], time = %ld , errmsg = [%s]\n"
        , dwResult, oStub.GetLastConsumeTime(),oStub.GetLastErrMsg());
    }
}
void TestGetSoso2Coordinates()
{
	//TODO 如果使用配置中心来获取APP地址,请注释下行
	CCGI_STUB_CNTL->setPeerAddr("10.12.192.209", 53101);

	//TODO 请设置用户Passport
	CCntlInfo oCntlInfo;
	oCntlInfo.setOperatorUin(88883687);
	oCntlInfo.setOperatorClientIP(0);
	oCntlInfo.setOperatorKey("stw3ymf9uk");
	//TODO 请设置路由值
	oCntlInfo.setRouteKey(88883687);
	std::string machineKey = "shellexchen";		
	std::string source = "shellex";		
	uint32_t sceneId = 0;
	erp::gis::po::CCoordinatesQueryPo coordinatesQueryPo;
    //coordinatesQueryPo.SetDestAddrProvince("");
    coordinatesQueryPo.SetDestAddrCity("深圳市");
    coordinatesQueryPo.SetDestAddrDistrict("");
	coordinatesQueryPo.SetDestAddrDetail("深圳市腾讯大厦");
	std::string inReserve = "";		
	std::vector<erp::gis::po::CCoordinatesPo > coordinatesPo;
	std::string errMsg = "";		
	std::string outReserve = "";		
	CGisMapGatewayAoStub4Web oStub;
	// TODO:替换函数参数
    uint32_t dwResult = oStub.GetSoso2Coordinates(
		oCntlInfo,
		machineKey,
		source,
		sceneId,
		coordinatesQueryPo,
		inReserve,
		coordinatesPo,
		errMsg,
		outReserve
  	);
    if(dwResult == 0)
	{
		std::cout << "Invoke OK!" << std::endl;
		printf("OK result[0x%x], time = %ld\n"
        , dwResult, oStub.GetLastConsumeTime());
        for(std::vector<erp::gis::po::CCoordinatesPo >::iterator iter = coordinatesPo.begin(); iter != coordinatesPo.end(); ++iter )
        {
            std::stringstream oss;
            iter->DumpData(oss);
            std::cout << oss.str() << std::endl;
        }

	}
	else
    {
        printf("Error result[0x%x], time = %ld , errmsg = [%s]\n"
        , dwResult, oStub.GetLastConsumeTime(),oStub.GetLastErrMsg());
    }
}
void TestGetSosoCoordinates()
{
	//TODO 如果使用配置中心来获取APP地址,请注释下行
	CCGI_STUB_CNTL->setPeerAddr("10.12.192.209", 53101);

	//TODO 请设置用户Passport
	CCntlInfo oCntlInfo;
	oCntlInfo.setOperatorUin(88883687);
	oCntlInfo.setOperatorClientIP(0);
	oCntlInfo.setOperatorKey("stw3ymf9uk");
	//TODO 请设置路由值
	oCntlInfo.setRouteKey(88883687);
	std::string machineKey = "shellexchen";		
	std::string source = "shellex";		
	uint32_t sceneId = 0;
	erp::gis::po::CCoordinatesQueryPo coordinatesQueryPo;
    //coordinatesQueryPo.SetDestAddrProvince("");
    coordinatesQueryPo.SetDestAddrCity("深圳市");
    coordinatesQueryPo.SetDestAddrDistrict("");
	coordinatesQueryPo.SetDestAddrDetail("深圳市腾讯大厦");
	std::string inReserve = "";		
	std::vector<erp::gis::po::CCoordinatesPo > coordinatesPo;
	std::string errMsg = "";		
	std::string outReserve = "";		
	CGisMapGatewayAoStub4Web oStub;
	// TODO:替换函数参数
    uint32_t dwResult = oStub.GetSosoCoordinates(
		oCntlInfo,
		machineKey,
		source,
		sceneId,
		coordinatesQueryPo,
		inReserve,
		coordinatesPo,
		errMsg,
		outReserve
  	);
    if(dwResult == 0)
	{
		std::cout << "Invoke OK!" << std::endl;
		printf("OK result[0x%x], time = %ld\n"
        , dwResult, oStub.GetLastConsumeTime());
        for(std::vector<erp::gis::po::CCoordinatesPo >::iterator iter = coordinatesPo.begin(); iter != coordinatesPo.end(); ++iter )
        {
            std::stringstream oss;
            iter->DumpData(oss);
            std::cout << oss.str() << std::endl;
        }

	}
	else
    {
        printf("Error result[0x%x], time = %ld , errmsg = [%s]\n"
        , dwResult, oStub.GetLastConsumeTime(),oStub.GetLastErrMsg());
    }
}
//测试主函数
int main(int argc, char** argv)
{
	//
	//测试主流程
	// 开发人员可以根据业务需要进行顺序的调整，以期达到更好的测试效果
	// 比如，可以按照插入、选择、修改、选择、删除、选择 顺序进行处理
	//
	Init();
	std::string str = "soso";
	if (argc > 1)
		str = argv[1];
	if (str == "aliyun")
	TestGetAliyunCoordinates();
	if (str == "baidu")
	TestGetBaiduCoordinates();
	if (str == "gaode")
	TestGetGaodeCoordinates();
	if (str == "google")
	TestGetGoogleCoordinates();
	if (str == "soso2")
	TestGetSoso2Coordinates();
	if (str == "soso")
	TestGetSosoCoordinates();
	return 0;
}
